﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;

namespace DistributedVisionRunner.Module.Converters
{
    public class PlacementVisibleConverter : MarkupExtension, IValueConverter
    {
        public ItemPlacementMethod VisiblePlacement { get; set; }

        public bool Invert { get; set; }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return this;
        }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var placement = (ItemPlacementMethod)value;

            if (!Invert)
            {
                return placement == VisiblePlacement ? Visibility.Visible : Visibility.Collapsed;
            }

            return placement != VisiblePlacement ? Visibility.Visible : Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}